{% extends 'base.html' %}
	
{% block content %}
	<div class="content">
		<script>
			$("#timelines_menu").addClass("selected");
		</script>  
		
		{% ifequal action "Edit" %}
			<h4>{{ timeline.title }}</h4>
			<h6>{{ timeline.description }}</h6>
			<h5>
				{% if not creator %}
					Esta timeline esta sem dono.
				{% else %}
					{{ timeline.creator }}
				{% endif %}
			</h5>
		{% endifequal %}
		
		{% if form.errors %}
			<p style="color:red;"> Algum erro.</p>
		{% endif %}
	
		<h1>Nova Timeline</h1>

		<form action="" method="post">
			<table class="timeline_form">
				{{ form.as_table }}
				<script>
					$("#id_initial_date").datepicker({dateFormat: 'dd/mm/yy'});
					$("#id_final_date").datepicker({dateFormat: 'dd/mm/yy'});
					
					$("#id_title").attr("value", "{{ timeline.title }}");
					$("#id_creator").attr("value", "{{ timeline.creator }}");
					$("#id_description").attr("value", "{{ timeline.description }}");
					$("#id_initial_date").attr("value", "{{ timeline.initial_date }}");
					
					$("#id_cover").attr("value", "{{ cover.media }}");
					$("#id_caption").attr("value", "{{ cover.caption }}");
					$("#id_credit").attr("value", "{{ cover.credit }}");
					
				</script>
			</table>
			
			{% ifequal action "Add" %}
				<input type="submit" value="Adicionar" class="button" />
			{% else %}
				<input type="submit" value="Editar" class="button" />
			{% endifequal %}
			
		</form>	
	</div>
{% endblock %}
